package org.chen.bas.service.lmpl;

import org.chen.bas.mapper.BasMapper;
import org.chen.bas.query.BasQuery;
import org.chen.bas.service.IBasService;
import org.chen.bas.util.PageInfo;

import org.chen.org.mapper.EmployeeMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.io.Serializable;
import java.util.List;
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class BasServiceImpl<T> implements IBasService<T> {
    @Autowired
    BasMapper<T> mapper;

    @Override
    public List<T> selectAll() {
        return mapper.selectAll();
    }
    @Transactional
    @Override
    public void insert(T t) {
        mapper.insert(t);
    }
    @Transactional
    @Override
    public void update(T t) {
        mapper.update(t);
    }

    @Transactional
    @Override
    public void delete(Serializable id) {
        mapper.delete(id);
    }

    @Override
    public T selectById(Serializable id) {
        return mapper.selectById(id);
    }



    @Override
    public PageInfo queryPage(BasQuery basQuery) {
        //查数据总条数
        Long total = mapper.queryTotal(basQuery);
        if (total>0){
            //查数据
            List<T> list=mapper.queryList(basQuery);
            return new PageInfo<T>(total,list);
        }

        return new PageInfo<T>();
    }
    @Override
    public void batchDelete(List<Long> ids) {
        mapper.batchDelete(ids);
    }
}
